﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace DATN.mds.Note
{
    public partial class CreateNote : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Name.Text = "Name";
            Descrip.Text = "Descrip";
            TimeRemind.Text = "Time";
            Date.Text = "Date";
            
        }

        protected void but_create_Click(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string name = name_txt.Text;
                string description = Descrip_txt.Text;
                string time = date_txt.Text+ " " +remind_txt.Text;

                DateTime time1 = DateTime.Parse(time);

                time = time1.ToString("MM/dd/yyyy hh:mm:ss");

                //string date = date_txt.Text;
                //date += " " + time;
                //Name.Text = name;
                //Descrip.Text = description;
                //TimeRemind.Text = time;
                //Date.Text = date.ToString();
                //string date1 = date.ToString("mm/dd/yyyy");
                //string us_id = Session["Us_Id"];

                SqlConnection cnn = new SqlConnection();
                cnn.ConnectionString = ConfigurationManager.ConnectionStrings["DATNconnection"].ToString();
                SqlCommand cmd = cnn.CreateCommand();

                string com1 = "Insert into Notes (Name, Description, TimeRemind, Us_Id)" +
                    "" + "values(N'" + name + "',N'" + description + "','" + time + "','"+Convert.ToInt32(Session["Us_Id"].ToString()) + "')";
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = com1;


                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Close();
                Page.Response.Redirect("~/mds.Note/IndexNote.aspx");
            
                
            }
        }

      
    }
}